-- 体现 Lua 的原子性，快速性，代码可替换性
local key1= KEYS[1]
local key2= KEYS[2]

local Amount= tonumber(ARGV[1])
local is_exists1 = redis.call ("EXISTS",key1)
local is_exists2 = redis.call ("EXISTS",key1)
    if is_exists1 == 1 and is_exists2== 1 then
    redis.call ("DecrBy", keyl, Amount)
    redis.call ("Set",key2, Amount)
    return 0
else
    return 1
end